function arrObj(arr) {
  const obj = {};
  for (let i = 0; i < arr.length; i++) {
    const item = arr[i];
    if (obj[item]) {
      obj[item]++;
    } else {
      obj[item] = 1;
    }
  }
  return obj;
}
console.log(arrObj(["b", "c", "b", "c", "a", "b", "c", "ss", "s", "a"]));
// 查找出现次数最多的元素
function maxObj(obj) {
  let max = 0;
  let maxKey = null;
  for (const key in obj) {
    if (obj[key] > max) {
      max = obj[key];
      maxKey = key;
    }
  }
  return { max, maxKey };
}
console.log(maxObj({ b: 3, c: 3, a: 2, ss: 1, s: 1 }));
// 去重数组
function unique(arr) {
  const obj = {};
  const result = [];
  for (let i = 0; i < arr.length; i++) {
    const item = arr[i];
    if (!obj[item]) {
      obj[item] = 1;
      result.push(item);
    }
  }
  return result;
}
console.log(unique(["b", "c", "b", "c", "a", "b", "c", "ss", "s", "a"]));
function unkkx(aee) {
  let result = [];
  let obj = {};
  for (let i = 0; i < aee.length; i++) {
    let item = aee[i];
    if (obj[item]) {
      obj[item]++;
    } else {
      obj[item] = 1;
      result.push(item);
    }
  }
  return result;
}
console.log(unkkx(["b", "c", "b", "c", "a", "b", "c", "ss", "s", "a"]));
